package com.by.config;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SmsConfig {
    @Autowired
    SmsProperties smsProperties;
    @Bean
    public Client smsClient(){
        // 注意引入正确的包
        Config config = new Config();
        config.setAccessKeyId(smsProperties.getAccessKeyId());
        config.setAccessKeySecret(smsProperties.getAccessKeySecret());
        config.setEndpoint(smsProperties.getEndpoint());
        try {
            return new Client(config);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
